package com.zking.service.impl;

import com.zking.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import tk.mybatis.mapper.common.Mapper;

import java.io.Serializable;
import java.util.List;

public abstract class BaseServiceImpl<T> implements BaseService<T> {

    @Autowired
    Mapper<T> mapper;

    @Override
    public List<T> selectAll() {
        return mapper.selectAll();
    }

    @Override
    public T selectById(Serializable id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public boolean update(T t) {
        return mapper.updateByPrimaryKeySelective(t) > 0;
    }

    @Override
    public boolean delete(Serializable id) {
        return mapper.deleteByPrimaryKey(id) > 0;
    }

    @Override
    public boolean insert(T t) {
        return mapper.insertSelective(t) > 0;
    }
}
